package xyz.cloorc.xzip

import org.springframework.boot.CommandLineRunner
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.core.env.SimpleCommandLinePropertySource
import xyz.cloorc.xzip.hex.HexUngzip;

/**
 * Created by Soiff on 2016/4/10.
 *
 * @author : wittcnezh@foxmail.com
 * @version : 1.0
 */
@SpringBootApplication
public class UnzipApplication implements CommandLineRunner {

    public static void main (String... args) {
        SpringApplication.run(UnzipApplication.class, args)
    }

    void run(String... args) throws Exception {
        SimpleCommandLinePropertySource source = new SimpleCommandLinePropertySource(args)
        Unzip unzip = new HexUngzip();
        InputStream is = System.in
        if (source.containsProperty("input"))
            is = new FileInputStream(source.getProperty("input"))

        OutputStream os = System.out
        if (source.containsProperty("output"))
            os = new FileOutputStream(source.getProperty("output"))

        unzip.unzip(is, os)
    }
}
